package offer;

import java.util.ArrayList;
import java.util.List;

public class offer_0006 {
    public int[] reversePrint(ListNode head) {
        List<Integer> list=new ArrayList<>();
        ListNode p=head;
        if(p==null) return new int[0];
        while(p!=null){
            list.add(p.val);
            p=p.next;
        }
        int len=list.size();
        int[] result=new int[len];
        for(int i=0;i<len;++i){
            result[i]=list.get(len-1-i);
        }
        return result;
    }
}
 class ListNode {
     int val;
     ListNode next;
     ListNode(int x) { val = x; }
 }